import eslint from "rollup-plugin-eslint";
import commonjs from "rollup-plugin-commonjs";
import resolve from "rollup-plugin-node-resolve";
import globals from "rollup-plugin-node-globals";
import builtins from "rollup-plugin-node-builtins";
import babel from "rollup-plugin-babel";
import clear from "rollup-plugin-clear";
import replace from "rollup-plugin-replace";
import json from "rollup-plugin-json";
import flow from "rollup-plugin-flow";
// import { uglify } from "rollup-plugin-uglify";
// import uglifyEs from "rollup-plugin-uglify-es";
import { version } from "./package.json";

export default {
    input: "./src/index.js",
    plugins: [
        clear({
            targets: ["./dist"],
            watch: true
        }),
        eslint(),
        commonjs({ include: "node_modules/**", extensions: [".js"] }),
        resolve({
            module: true,
            jsnext: true,
            // builtins: false,
            main: true,
            browser: true,
            extensions: [".js", ".json"]
        }),
        flow({
            pretty: true
        }),
        json(),
        globals(),
        builtins(),
        babel({
            exclude: "node_modules/**",
            runtimeHelpers: true,
            externalHelpers: true
        }),
        replace({
            "process.env.NODE_ENV": JSON.stringify("production")
        })
        // uglifyEs(),
        // uglify({
        //   output: {
        //     comments: 'all',
        //   },
        // }),
    ],
    external: [],
    output: {
        banner:
            "/** @license ZSearch v" +
            version +
            "\n*\n* Copyright (c) 2018-present, wangzhe, Inc.\n*\n* This source code is licensed under the MIT license found in the\n* LICENSE file in the root directory of this source tree.\n*/",
        file: "./dist/ZSearch.js",
        format: "umd",
        name: "ZSearch",
        sourceMap: false
    }
};
